import handleNum from './Num'

// 数据的初始化
const defaultState = {
  ...handleNum.state //解构
}

let reducer = (state = defaultState, action: { type: string, val: number }) => {
  let newState = JSON.parse(JSON.stringify(state))

  switch (action.type) {
    case 'add1':
      // newState.num++
      handleNum.actions.add1(newState)
      break

    case 'add2':
      // newState.num += action.val
      handleNum.actions.add2(newState, action)
      break

    default:
      break
  }


  return newState
}

export default reducer